﻿cmake_minimum_required(VERSION 3.16)

project(MeasureView
    VERSION 2.0.0
    DESCRIPTION "A Image View Widget and some util class."
    LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)

set(TS_FILES MeasureView_zh_CN.ts)

add_library(MeasureView SHARED
  ${TS_FILES}
  src/DialogMeasure.cpp
  src/DialogMeasure.ui
  include/MeasureView/DialogMeasure.h
  include/MeasureView/ColorComboBox.h
  include/MeasureView/ImageView.h
  # include/MeasureView/MeasureAlgorithm.h
  # include/MeasureView/MeasureAngle.h
  # include/MeasureView/MeasureArc3P.h
  # include/MeasureView/MeasureCircle2Circle.h
  # include/MeasureView/MeasureCircle2P.h
  # include/MeasureView/MeasureCircle2PSA.h
  # include/MeasureView/MeasureCircle3P.h
  # include/MeasureView/MeasureCircleCenter.h
  # include/MeasureView/MeasureCircleCenterSA.h
  # include/MeasureView/MeasureCount.h
  include/MeasureView/MeasureDataSet.h
  # include/MeasureView/MeasureDots2Line.h
  # include/MeasureView/MeasureElement.h
  # include/MeasureView/MeasureLine.h
  # include/MeasureView/MeasureLineWidthSA.h
  # include/MeasureView/MeasureLineWidthSA2.h
  # include/MeasureView/MeasureParallelLine.h
  # include/MeasureView/MeasurePolygon.h
  # include/MeasureView/MeasurePolyline.h
  # include/MeasureView/MeasureRect.h
  # include/MeasureView/MeasureView.h
  # include/MeasureView/TextBlock.h
  include/MeasureView/ToolBarMeasure.h
  include/MeasureView/ToolBarProperty.h
  include/MeasureView/ToolBarSemiAutoMeasure.h
  include/MeasureView/ToolBarZoom.h
  # include/MeasureView/UnitConvert.h
  src/ImageView.cpp
  src/MeasureAlgorithm.cpp
  src/MeasureAngle.cpp
  src/MeasureArc3P.cpp
  src/MeasureCircle2Circle.cpp
  src/MeasureCircle2P.cpp
  src/MeasureCircle3P.cpp
  src/MeasureCircleCenter.cpp
  src/MeasureCount.cpp
  src/MeasureDataSet.cpp
  src/MeasureDots2Line.cpp
  src/MeasureElement.cpp
  src/MeasureLine.cpp
  src/MeasureParallelLine.cpp
  src/MeasurePolygon.cpp
  src/MeasurePolyline.cpp
  src/MeasureRect.cpp
  src/MeasureView.cpp
  src/TextBlock.cpp
  src/UnitConvert.cpp
  src/toolbar/ColorComboBox.cpp
  src/toolbar/ToolBarMeasure.cpp
  src/toolbar/ToolBarProperty.cpp
  src/toolbar/ToolBarSemiAutoMeasure.cpp
  src/toolbar/ToolBarZoom.cpp
  src/SemiAutoMeasure/DialogSemiAutoMeasure.ui
  src/SemiAutoMeasure/DialogSemiAutoMeasure.cpp
  include/SemiAutoMeasure/DialogSemiAutoMeasure.h
  src/SemiAutoMeasure/cagaus.cpp
  src/SemiAutoMeasure/CircleFitSolver_OpenCV.cpp
  src/SemiAutoMeasure/MeasureCircle2PSA.cpp
  src/SemiAutoMeasure/MeasureCircleCenterSA.cpp
  src/SemiAutoMeasure/MeasureLineWidthSA.cpp
  src/SemiAutoMeasure/plinesfit_opencv.cpp
  src/SemiAutoMeasure/SemiAutoMeasure.cpp
  include/SemiAutoMeasure/SemiAutoMeasure.h
  #SemiAutoMeasure/MeasureLineWidthSA2.cpp
  res/res.qrc
)

set_target_properties(MeasureView PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
DEBUG_POSTFIX d)

find_package(GSL REQUIRED)
target_link_libraries(MeasureView PRIVATE GSL::gsl GSL::gslcblas)

#set(OpenCV_ROOT "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4")
find_package(OpenCV REQUIRED)
target_link_libraries(MeasureView PUBLIC opencv_core opencv_imgproc opencv_highgui)

target_link_libraries(MeasureView PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_include_directories(MeasureView PUBLIC ${PROJECT_SOURCE_DIR}/include/)
target_compile_definitions(MeasureView PRIVATE MEASUREVIEW_LIBRARY)

if(COMMAND qt_create_translation)
    qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
    qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
